﻿@model RMS.Models.Problem
@using RMS.Models
@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm("Create","Problem",FormMethod.Post)) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Problem</legend>


        <div class="editor-label">
            @Html.Label("company", "Company")
        </div>
        <div class="editor-field">
            @Html.Encode(((Company)ViewData["company"]).Name)
            @Html.Hidden("companyId",((Company)ViewData["company"]).Name)
            <input type="hidden" id="CreateUserId" name="CreateUserId" value="@ViewData["userId"]" />
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ProblemGroup)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.ProblemGroupId,
            new SelectList(
                (IEnumerable<RMS.Models.ProblemGroup>)ViewData["problemGroups"],"Id","Name"))
            @Html.ValidationMessageFor(model => model.ProblemGroupId)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.RiskType)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.RiskTypeId,
            new SelectList(
                (IEnumerable<RMS.Models.RiskType>)ViewData["riskTypes"],"Id","Name"))
            @Html.ValidationMessageFor(model => model.ProblemGroupId)
        </div>

        <div class="editor-label">
            @Html.Label("product","Product")
        </div>
        <div class="editor-field">
            @if (ViewData["productId"] != null)
            {
                @Html.Encode(ViewData["productName"])
                @Html.Hidden("ProductId", ViewData["productId"])
            }
            else
            {
                @Html.Encode("General Problem")
            }
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Causation)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Causation)
        </div>


        <p>
            <input type="submit" name="submit" value="Submit" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

